//
//  ESWeChatTableViewcell.m
//  EasyStyle
//
//  Created by FK on 15/12/28.
//  Copyright © 2015年 FK. All rights reserved.
//

#import "ESWeChatTableViewcell.h"
#import "UIImageView+WebCache.h"

@implementation ESWeChatTableViewcell
- (void)awakeFromNib {
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    self.titleLable.text = _newsObject.title;
    self.sourceLable.text = _newsObject.source;
    NSLog(@"URL == %@",_newsObject.firstImg);
    if (_newsObject.firstImg.length <= 0) {
        [self.firstImg removeFromSuperview];
        
        NSLayoutConstraint* leftConstraint = [NSLayoutConstraint constraintWithItem:self.titleLable attribute:NSLayoutAttributeLeading relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeLeading multiplier:1.0f constant:13.0f];

        NSLayoutConstraint* rightConstraint = [NSLayoutConstraint constraintWithItem:self.titleLable attribute:NSLayoutAttributeTrailing relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeTrailing multiplier:1.0f constant:-13.0f];
        
        [self addConstraints:@[leftConstraint,rightConstraint]];
        
    } else {
        [self.firstImg sd_setImageWithURL:[NSURL URLWithString:_newsObject.firstImg] placeholderImage:[UIImage imageNamed:@"NewsListdefult.png"]];
    }
    
}
@end
